<template>
  <!-- 基本信息-->
  <div class="bg-white my-[10px]">
    <BaseHead style="border-bottom: 0">基本信息</BaseHead>
    <BaseTable>
      <tr>
        <td class="td-name">批准号</td>
        <td colspan="3">{{ detailData.authorizeCode }}</td>
      </tr>
      <tr>
        <td class="td-name">项目名称</td>
        <td>{{ detailData.name }}</td>
        <td class="td-name">项目编号</td>
        <td>{{ detailData.code ? detailData.code : "审核通过后生成" }}</td>
      </tr>
      <tr>
        <td class="td-name">负责人</td>
        <td>{{ detailData.chargerName }}</td>
        <td class="td-name">负责人类型</td>
        <td><CommonLabel :dataList="memberTypeList" :value="detailData.chargerType" /></td>
      </tr>
      <tr>
        <td class="td-name">所属单位</td>
        <td>
          <CommonTreeLabel
            :dataList="unitList"
            :value="detailData.unitId"
            valueKey="codeColumn"
            labelKey="valueColumn"
          />
        </td>
        <td class="td-name">项目分类</td>
        <td>
          <CommonTreeLabel
            :dataList="projectTypeList"
            :value="detailData.projectTypeCode"
            labelKey="labelLocal"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">项目级别</td>
        <td><CommonLabel :dataList="projectLevelList" :value="detailData.projectLevelId" /></td>
        <td class="td-name">项目来源单位</td>
        <td>{{ detailData.projectTier }}</td>
      </tr>
      <tr>
        <td class="td-name">项目状态</td>
        <td><CommonLabel :dataList="projectStatusList" :value="detailData.projectStatusId" /></td>
        <td class="td-name">立项日期</td>
        <td>{{ detailData.authorizeDate }}</td>
      </tr>
      <tr>
        <td class="td-name">开始日期</td>
        <td>{{ detailData.beginDate }}</td>
        <td class="td-name">计划结项日期</td>
        <td>{{ detailData.planEndDate }}</td>
      </tr>
      <tr>
        <td class="td-name">结项日期</td>
        <td>{{ detailData.actualEndDate }}</td>
        <td class="td-name">项目总经费</td>
        <td>{{ detailData.feeAuthorize }} 万元</td>
      </tr>
      <tr>
        <td class="td-name">拨款金额</td>
        <td>{{ detailData.selfProvideFee }} 万元</td>
        <td class="td-name">学校资助经费</td>
        <td>{{ detailData.attachFee }} 万元</td>
      </tr>
      <tr>
        <td class="td-name">外拨经费</td>
        <td>{{ detailData.outFee }} 万元</td>
        <td class="td-name">成果形式</td>
        <td>{{ detailData.productMode }}</td>
      </tr>
    </BaseTable>
  </div>
  <!-- 教育部统计信息 -->
  <div class="bg-white">
    <BaseHead style="border-bottom: 0">教育部统计信息 </BaseHead>
    <BaseTable>
      <tr>
        <td class="td-name">统计归属</td>
        <td><CommonLabel :dataList="tjgsList" :value="detailData.subjectClassId" /></td>
        <td class="td-name">一级学科</td>
        <td>
          <CommonLabel
            :dataList="subjectList.value"
            :value="detailData.subjectId"
            labelKey="label"
            valueKey="id"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">社会经济服务目标</td>
        <td><CommonTreeLabel :dataList="jjfwmbList" :value="detailData.societyTarget" /></td>
        <td class="td-name">项目来源</td>
        <td>
          <CommonLabel
            :dataList="projectSourceList.value"
            :value="detailData.projectSourceId"
            labelKey="label"
            valueKey="id"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">研究类别</td>
        <td>
          <CommonLabel
            :dataList="researchTypeList.value"
            :value="detailData.researchClassId"
            labelKey="label"
            valueKey="id"
          />
        </td>
        <td class="td-name">国民经济行业</td>
        <td>
          <CommonTreeLabel :dataList="gmjjhyList" :value="detailData.gmjjhy" />
        </td>
      </tr>
    </BaseTable>
  </div>
  <!-- 详细信息 -->
  <div class="bg-white">
    <BaseHead style="border-bottom: 0">详细信息 </BaseHead>
    <BaseTable>
      <tr>
        <td class="td-name">课题类型</td>
        <td style="width: 87.5%">
          <CommonLabel :dataList="ktTypeList" :value="detailData.levelType" />
        </td>
      </tr>
      <template v-if="detailData.levelType == 2">
        <tr>
          <td class="td-name">课题性质</td>
          <td>
            <CommonLabel :dataList="ktxzList" :value="detailData.subjectNature" />
          </td>
        </tr>
        <template v-if="detailData.subjectNature != 'independent'">
          <tr>
            <td class="td-name">依托项目名称</td>
            <td>{{ detailData.upItemName }}</td>
          </tr>
          <tr>
            <td class="td-name">依托项目负责人</td>
            <td>{{ detailData.relyingProjectLeader }}</td>
          </tr>
          <tr v-if="detailData.subjectNature == 'otherSchool'">
            <td class="td-name">依托项目单位名称</td>
            <td>{{ detailData.relyingProjectUnitName }}</td>
          </tr>
        </template>
      </template>

      <template v-if="detailData.levelType == 3">
        <tr>
          <td class="td-name">牵头人单位</td>
          <td>{{ detailData.leadUnitName }}</td>
        </tr>
        <tr>
          <td class="td-name">牵头人单位负责人</td>
          <td>{{ detailData.leadUnitLeader }}</td>
        </tr>
      </template>
      <tr>
        <td class="td-name">备注</td>
        <td>{{ detailData.note }}</td>
      </tr>
    </BaseTable>
  </div>
</template>

<script setup>
import BaseHead from "@/views/project/components/BaseHead.vue";
import BaseTable from "@/views/project/components/BaseTable.vue";
import CommonLabel from "@/views/project/components/CommonLabel.vue";
import CommonTreeLabel from "@/views/project/components/CommonTreeLabel.vue";
import { baseDetail } from "@/api/project/zx/lxxm";
import useCommonFetch from "@/hooks/useCommonFetch";
const memberTypeList = inject("memberTypeList");
const unitList = inject("unitList");
const projectTypeList = inject("projectTypeList");
const projectLevelList = inject("projectLevelList");
const projectStatusList = inject("projectStatusList");
const tjgsList = inject("tjgsList");
const jjfwmbList = inject("jjfwmbList");
const gmjjhyList = inject("gmjjhyList");
const ktTypeList = inject("ktTypeList");
const ktxzList = inject("ktxzList");
let subjectList = ref([]); //一级学科下拉数据
let researchTypeList = ref([]); //研究类别下拉数据
let projectSourceList = ref([]); //项目来源下拉数据
const operateId = inject("id");
const detailData = ref({});
//获取数据详情
const getDetail = async () => {
  try {
    const res = await baseDetail(operateId.value);
    detailData.value = res.data;
    subjectList.value = useCommonFetch("一级学科", detailData.value.subjectClassId);
    researchTypeList.value = useCommonFetch("研究类别", detailData.value.subjectClassId);
    projectSourceList.value = useCommonFetch("项目来源", detailData.value.subjectClassId);
  } catch (error) {
    console.log(error);
  }
};
onMounted(() => {
  getDetail();
});
</script>

<style scoped lang="scss"></style>
